package com.jd.basic.controller;

import com.jd.basic.dto.BinderDto;
import com.jd.basic.dto.LoginDto;
import com.jd.basic.dto.WeChatDto;
import com.jd.basic.service.LoginService;
import com.jd.basic.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;

@RestController
@RequestMapping("/login")
public class LoginController {
    @Autowired
    LoginService loginService;

    @PostMapping("/user")
    public AjaxResult login(@RequestBody @Valid LoginDto dto){
        System.err.println("参数" + dto);
        System.err.println(loginService.login(dto));
        return loginService.login(dto);
    }

    @PostMapping("/wechat")
    public AjaxResult wechat(@RequestBody @Valid WeChatDto weChatDto){
        System.err.println("微信登录" + weChatDto);
        return loginService.wechat(weChatDto);
    }

    @PostMapping("/binder")
    public AjaxResult binder(@RequestBody @Valid BinderDto binderDto){

        return loginService.binder(binderDto);
    }
}
